//
//  BannerViewController.m
//  GOGOTravel
//
//  Created by dllo on 16/1/31.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "BannerViewController.h"

@interface BannerViewController ()<UIWebViewDelegate>

@property (nonatomic, retain) UIWebView *web;
@property (nonatomic, retain) UIActivityIndicatorView *activity;
@property (nonatomic, retain) UIView *view1;

@end

@implementation BannerViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)dealloc{
    [_URL release];
    [_web release];
    [_activity release];
    [_view1 release];
    [super dealloc];
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"活动详情";
    self.view.backgroundColor = [UIColor whiteColor];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"iconfont-fenxiang.png"] style:UIBarButtonItemStylePlain target:self action:@selector(itemAction:)];
    
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed: @"iconfont-heilongjiangtubiao12.png"] style:UIBarButtonItemStylePlain target:self action:@selector(item1Action:)];
    
    self.navigationItem.rightBarButtonItems = @[item, item1];
    
    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"iconfont-jiantouzuo.png"] style:UIBarButtonItemStylePlain target:self action:@selector(item2Action:)];
    self.navigationItem.leftBarButtonItem = item2;
    
    
    
    
    [self createwebView];
    
    
    self.view1 = [[UIView alloc] initWithFrame:self.view.bounds];
    _view1.backgroundColor = [UIColor blackColor];
    _view1.alpha = 0.5;
    
    [self.view addSubview:_view1];
    [_view1 release];
    
    
}

- (void)itemAction:(UIBarButtonItem *)item{
    
}
- (void)item1Action:(UIBarButtonItem *)item{
    
}
- (void)item2Action:(UIBarButtonItem *)item{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)createwebView{
    self.web = [[UIWebView alloc] init];
    _web.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
    
    [_web loadRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:_URL]]];
    
    _web.delegate = self;
    
    [self.view addSubview:_web];
    
}


#pragma mark-webView代理方法
- (void)webViewDidStartLoad:(UIWebView *)webView{
    
    
    
    self.activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    
    
    _activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    
    [_view1 addSubview:_activity];
    _activity.center = _view1.center;
    [_activity release];
    
    [_activity startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [_activity stopAnimating];
    [_view1 removeFromSuperview];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
